// 目标
const rootElement = document.body;
// 关键字，一行一个
const keywords = `
请大家收藏
`;
const keywordArray: string[] = keywords.split("\n").filter((v) => !!v);

function hideNodes(nodes: NodeList | null) {
  for (const node of nodes ?? []) {
    for (const keyword of keywordArray) {
      if (node.textContent?.includes(keyword)) {
        (node as HTMLElement).style.cssText = "display: none !important;";
      }
    }
  }
}

const observer = new MutationObserver((records) => {
  for (const record of records) {
    if (record.type === "childList") {
      hideNodes(record.addedNodes);
    }
  }
});

// 先清除一遍
hideNodes(rootElement.querySelectorAll("p"));

// 开始监控
observer.observe(rootElement, {
  childList: true,
  subtree: true,
});
